"""
门户网站 API URL 配置
"""

from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import (
    HomePageView,
    ProductListView,
    ProductDetailView,
    CategoryListView,
    SearchView,
)
from .views.user import UserViewSet
from .views.cart import CartViewSet
from .views.order import OrderViewSet

app_name = 'shop'

# 创建路由器
router = DefaultRouter()
router.register(r'users', UserViewSet, basename='user')
router.register(r'cart', CartViewSet, basename='cart')
router.register(r'orders', OrderViewSet, basename='order')

urlpatterns = [
    # 首页
    path('home/', HomePageView.as_view(), name='home'),
    
    # 产品
    path('products/', ProductListView.as_view(), name='product-list'),
    path('products/<int:pk>/', ProductDetailView.as_view(), name='product-detail'),
    
    # 分类
    path('categories/', CategoryListView.as_view(), name='category-list'),
    
    # 搜索
    path('search/', SearchView.as_view(), name='search'),
    
    # 用户和购物车 (通过router)
    path('', include(router.urls)),
]

